﻿Public Class KetNoi
    Public ketnoi As Boolean
    Public constr As String
    
    Dim provider As DataProvider


    Private Sub btnketnoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnketnoi.Click
        Dim provider As New DataProvider
        Dim maychu As String = txtmaychu.Text
        Dim csdl As String = txtcsdl.Text
        Dim strerror As String = ""
        strerror = provider.Ketnoi(maychu, csdl)
      
        If strerror = "" Then
            ketnoi = True
            provider.SqlConnectionStr = "Data Source=" + maychu + ";Initial Catalog=" + csdl + ";Integrated Security=True"
            Me.Close()
        Else
            MessageBox.Show(" Kiểm tra lại kết nối")
            Me.Show()
        End If
    End Sub

    Private Sub KetNoi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cbxchungthuc.SelectedIndex = 0

    End Sub

    Private Sub btnthoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthoat.Click
        ketnoi = False
        Me.Close()
    End Sub
End Class